package com.youdoneed.community.accounts.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.youdoneed.community.accounts.dao.CompanybillMapper;
import com.youdoneed.community.accounts.entity.Companybill;

@Service
public class CompanyBillService  {

	private final Logger logger = LoggerFactory.getLogger(CompanyBillService.class);
	@Autowired
	CompanybillMapper companybillMapper;

	@Transactional
    public boolean save(Companybill bill){
    	try {
    		companybillMapper.insert(bill);
    		return true;
		} catch (Exception e) {
			logger.error("公司开票保存错误:"+e);
			return false;
		}
    }

	@Transactional
    public boolean update(Companybill bill){
    	try {
    		companybillMapper.updateByPrimaryKey(bill);
    		return true;
		} catch (Exception e) {
			logger.error("公司开票更新错误:"+e);
			return false;
		}
    }

	@Transactional
    public boolean delete(String id){
    	try {
    		companybillMapper.deleteByPrimaryKey(id);
    		return true;
		} catch (Exception e) {
			logger.error("公司开票删除错误:"+e);
			return false;
		}
    }
    
	@Transactional
    public Companybill selectById(String id){
    	try {
    		return companybillMapper.selectByPrimaryKey(id);
		} catch (Exception e) {
			logger.error("公司开票按ID查询错误:"+e);
			return null;
		}
    }
    
}
